package com.xhcl.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.TSrhsDwcx;
import com.xhcl.system.service.ITSrhsDwcxService;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 单位查询定义Controller
 * 
 * @author xhcl
 * @date 2020-08-30
 */
@Controller
@RequestMapping("/system/dwcxdy")
public class TSrhsDwcxdyController extends BaseController
{
    private String prefix = "system/dwcxdy";

    @Autowired
    private ITSrhsDwcxService tSrhsDwcxService;

    @RequiresPermissions("system:dwcxdy:view")
    @GetMapping()
    public String dwcxdy()
    {
        return prefix + "/dwcxdy";
    }

    /**
     * 查询单位查询定义列表
     */
    @RequiresPermissions("system:dwcxdy:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSrhsDwcx tSrhsDwcx)
    {
        startPage();
        List<TSrhsDwcx> list = tSrhsDwcxService.selectTSrhsDwcxList(tSrhsDwcx);
        return getDataTable(list);
    }

    /**
     * 导出单位查询定义列表
     */
    @RequiresPermissions("system:dwcxdy:export")
    @Log(title = "单位查询定义", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSrhsDwcx tSrhsDwcx)
    {
        List<TSrhsDwcx> list = tSrhsDwcxService.selectTSrhsDwcxList(tSrhsDwcx);
        ExcelUtil<TSrhsDwcx> util = new ExcelUtil<TSrhsDwcx>(TSrhsDwcx.class);
        return util.exportExcel(list, "dwcxdy");
    }

    /**
     * 新增单位查询定义
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存单位查询定义
     */
    @RequiresPermissions("system:dwcxdy:add")
    @Log(title = "单位查询定义", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSrhsDwcx tSrhsDwcx)
    {
        return toAjax(tSrhsDwcxService.batchinsertTSrhsDwcx(tSrhsDwcx));
    }

    /**
     * 修改单位查询定义
     */
    @GetMapping("/edit/{zbh}")
    public String edit(@PathVariable("zbh") Long zbh, ModelMap mmap)
    {   
    	TSrhsDwcx tSrhsDwcx=new TSrhsDwcx();
    	tSrhsDwcx.setZbh(zbh);
        List<TSrhsDwcx> list = tSrhsDwcxService.selectTSrhsDwcxList(tSrhsDwcx);
        mmap.put("dwcxlist", list);
        return prefix + "/edit";
    }

    /**
     * 修改保存单位查询定义
     */
    @RequiresPermissions("system:dwcxdy:edit")
    @Log(title = "单位查询定义", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSrhsDwcx tSrhsDwcx)
    {
        return toAjax(tSrhsDwcxService.batchupdateTSrhsDwcx(tSrhsDwcx));
    }

    /**
     * 删除单位查询定义
     */
    @RequiresPermissions("system:dwcxdy:remove")
    @Log(title = "单位查询定义", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSrhsDwcxService.deleteTSrhsDwcxByIds(ids));
    }
}
